package com.raise.drive.commons.captcha;

import com.octo.captcha.component.image.backgroundgenerator.BackgroundGenerator;
import com.octo.captcha.component.image.backgroundgenerator.FunkyBackgroundGenerator;
import com.octo.captcha.component.image.fontgenerator.FontGenerator;
import com.octo.captcha.component.image.textpaster.RandomTextPaster;
import com.octo.captcha.component.image.textpaster.TextPaster;
import com.octo.captcha.component.image.wordtoimage.ComposedWordToImage;
import com.octo.captcha.component.image.wordtoimage.WordToImage;
import com.octo.captcha.component.word.wordgenerator.RandomWordGenerator;
import com.octo.captcha.component.word.wordgenerator.WordGenerator;
import com.octo.captcha.engine.image.ListImageCaptchaEngine;
import com.octo.captcha.image.gimpy.GimpyFactory;

import java.awt.*;


/**
 * <p>Description: </p>
 *
 * @version 1.0
 */
public class CaptchaEngine extends ListImageCaptchaEngine {

  protected void buildInitialFactories() {
    WordGenerator wordGenerator =
        new RandomWordGenerator("1234567890abcdefghijklmnopqrstuvwxyz");
    TextPaster textPaster = new RandomTextPaster(5, 6, Color.black);
    BackgroundGenerator backgroundGenerator =
        new FunkyBackgroundGenerator(200, 50);
    FontGenerator fontGenerator =
        new MyRandomFontGenerator(25, 30,
            new Font[] { new Font("SansSerif", 0, 15) });
    WordToImage wordToImage = new ComposedWordToImage(fontGenerator,
        backgroundGenerator, textPaster);
    this.addFactory(new GimpyFactory(wordGenerator, wordToImage));
  }
}
